package com.haoxiaozhang.hxz_app.viewLib.customDialog;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.View;

import com.haoxiaozhang.hxz_app.R;

import androidx.annotation.NonNull;

public abstract class CustomDialog extends Dialog {

    public abstract void onSubmit();
    public abstract void onCancel();


    public CustomDialog(@NonNull Context context, final int type) {
        super(context);
        setContentView(R.layout.custom_dialog);

        if(type == 0){
            findViewById(R.id.dialog_cancel).setVisibility(View.GONE);
        }

        findViewById(R.id.dialog_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(type == 1){
                    onSubmit();
                }
            }
        });

        findViewById(R.id.dialog_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                onCancel();
            }
        });

    }

}
